
<script setup>
	import add from './components/add.vue'
	import list from '@/components/list.vue'
	import { ref } from 'vue'
	import { onReachBottom,onPullDownRefresh } from '@dcloudio/uni-app'
	
	const udb = ref()
	onReachBottom(() => {
		udb.value.loadMore()
	})
	onPullDownRefresh(() => {
		udb.value.loadData({clear: true},() => {
			setTimeout(() => {
				uni.stopPullDownRefresh()
			},500)
		})
	})
	
</script>


<template>
	<add />
	<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}"
		where="isPublicity == true" collection="dynamic_list" orderby="createTime desc">
		<view v-if="error">{{error.message}}</view>
		<view class="loading flex" v-else-if="loading">
			正在加载中。。。
		</view>
		<view v-else>
			<list :data="data" />
		</view>
		<template v-if="!data.length">
			<u-empty marginTop="100" mode="list"></u-empty>
		</template>
	</unicloud-db>
</template>
<style lang="scss">
	.loading{
		position: fixed;
		left: 0;
		top: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0,0,0,.3);
	}
</style>